﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

using System.Data.SQLite;

namespace Classes
{
   public class OfficeList
   {
      #region Private Member Variables
      
      static private List<Office> list = null;
      
      #endregion
      
      #region Properties
      
      static public List<Office> List
      {
         get
         {
            if (list == null)
               Setup();
               
            return list;
         }
      }
     
      #endregion
      
      #region Setup
      
      static public void Setup()
      {
         list = new List<Office>();

         SQLiteConnection conn = new SQLiteConnection(@"Data Source=C:\Users\toadzky\Documents\Visual Studio 2010\Projects\APX_2010\2010.apx;");
         SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM Offices;", conn);
         conn.Open();

         SQLiteDataReader rows = cmd.ExecuteReader();

         while (rows.Read())
            list.Add(new Office(rows));

         list.Sort();

      }
      
      #endregion
   }
}
